﻿using Demo.Application.Dtos.Dept;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using PmSoft.Core;

namespace Demo.Application.Services.Dept;
[Inject(ServiceLifetime.Scoped)]
public class DeptService
{
	private readonly DeptRepository deptRepository;

	public DeptService(DeptRepository deptRepository)
	{
		this.deptRepository = deptRepository;
	}


	public async Task<DeptDto> GetDeptAsync(int deptId)
	{
		var dept = await deptRepository.GetAsync(deptId);
		return dept.Adapt<DeptDto>();
	}

	public async Task<IEnumerable<DeptDto>> GetDeptsAsync(IEnumerable<int> deptIds)
	{
		var depts = await deptRepository.GetEntitiesByIdsAsync(deptIds);
		return depts.Adapt<DeptDto[]>();
	}
}
